﻿using System;
using Assets.Scripts.GtsScripts;
using RootMotion;
using RootMotion.FinalIK;
using SteeringBehaviors;
using UnityEngine;

// Token: 0x02000171 RID: 369
public class GiantessIK : MonoBehaviour
{
	// Token: 0x17000104 RID: 260
	// (get) Token: 0x060006C0 RID: 1728 RVA: 0x0003AC5A File Offset: 0x00038E5A
	// (set) Token: 0x060006C1 RID: 1729 RVA: 0x0003AC62 File Offset: 0x00038E62
	public bool crushEnded { get; private set; }

	// Token: 0x17000105 RID: 261
	// (get) Token: 0x060006C2 RID: 1730 RVA: 0x0003AC6B File Offset: 0x00038E6B
	public GiantessIK.FootStates _footState
	{
		get
		{
			return this.footState;
		}
	}

	// Token: 0x17000106 RID: 262
	// (get) Token: 0x060006C3 RID: 1731 RVA: 0x0003AC73 File Offset: 0x00038E73
	// (set) Token: 0x060006C4 RID: 1732 RVA: 0x0003AC7B File Offset: 0x00038E7B
	public IKBone leftHandEffector { get; private set; }

	// Token: 0x17000107 RID: 263
	// (get) Token: 0x060006C5 RID: 1733 RVA: 0x0003AC84 File Offset: 0x00038E84
	// (set) Token: 0x060006C6 RID: 1734 RVA: 0x0003AC8C File Offset: 0x00038E8C
	public IKBone rightHandEffector { get; private set; }

	// Token: 0x17000108 RID: 264
	// (get) Token: 0x060006C7 RID: 1735 RVA: 0x0003AC95 File Offset: 0x00038E95
	// (set) Token: 0x060006C8 RID: 1736 RVA: 0x0003AC9D File Offset: 0x00038E9D
	public HandIK hand { get; private set; }

	// Token: 0x17000109 RID: 265
	// (get) Token: 0x060006C9 RID: 1737 RVA: 0x0003ACA6 File Offset: 0x00038EA6
	// (set) Token: 0x060006CA RID: 1738 RVA: 0x0003ACAE File Offset: 0x00038EAE
	public HeadIK head { get; private set; }

	// Token: 0x1700010A RID: 266
	// (get) Token: 0x060006CB RID: 1739 RVA: 0x0003ACB7 File Offset: 0x00038EB7
	// (set) Token: 0x060006CC RID: 1740 RVA: 0x0003ACBF File Offset: 0x00038EBF
	public PoseIK poseIK { get; private set; }

	// Token: 0x060006CD RID: 1741 RVA: 0x0003ACC8 File Offset: 0x00038EC8
	private void Awake()
	{
		this.giantess = base.GetComponent<Giantess>();
		this.anim = base.GetComponent<Animator>();
		this.headT = this.anim.GetBoneTransform(HumanBodyBones.Head);
		Transform boneTransform = this.anim.GetBoneTransform(HumanBodyBones.Spine);
		Transform boneTransform2 = this.anim.GetBoneTransform(HumanBodyBones.LeftEye);
		Transform boneTransform3 = this.anim.GetBoneTransform(HumanBodyBones.RightEye);
		this.rightFoot = this.anim.GetBoneTransform(HumanBodyBones.RightFoot);
		this.leftFoot = this.anim.GetBoneTransform(HumanBodyBones.LeftFoot);
		this.rightShoulder = this.anim.GetBoneTransform(HumanBodyBones.RightShoulder);
		this.hips = this.anim.GetBoneTransform(HumanBodyBones.Hips);
		BipedReferences references = new BipedReferences();
		BipedReferences.AutoDetectReferences(ref references, base.transform, BipedReferences.AutoDetectParams.Default);
		this.ik = base.gameObject.AddComponent<FullBodyBipedIK>();
		this.ik.solver.iterations = 3;
		this.ik.SetReferences(references, null);
		this.ik.solver.SetLimbOrientations(BipedLimbOrientations.UMA);
		this.SetDefaultValues();
		this.FindFootOffsets();
		this.bodyEffector = new IKBone(this.ik.solver.bodyEffector);
		this.leftFootEffector = new IKBone(this.ik.solver.leftFootEffector);
		this.rightFootEffector = new IKBone(this.ik.solver.rightFootEffector);
		this.leftHandEffector = new IKBone(this.ik.solver.leftHandEffector);
		this.rightHandEffector = new IKBone(this.ik.solver.rightHandEffector);
		this.useGrounder = GlobalPreferences.UseGrounder.value;
		if (this.useGrounder)
		{
			GameObject gameObject = new GameObject("ikObj");
			gameObject.transform.SetParent(base.gameObject.transform);
			this.grounder = gameObject.AddComponent<GrounderFBBIK>();
			this.grounder.solver.layers = Layers.stompingMask;
			this.grounder.solver.footSpeed = 10f;
			this.grounder.solver.maxFootRotationAngle = 20f;
			this.grounder.ik = this.ik;
		}
		this.lookAtIK = base.gameObject.AddComponent<LookAtIK>();
		this.lookAtIK.solver.SetChain(new Transform[]
		{
			boneTransform
		}, this.headT, new Transform[]
		{
			boneTransform2,
			boneTransform3
		}, base.transform.GetChild(0));
		this.head = new HeadIK(this.lookAtIK, this.giantess);
		this.playerCamera = Camera.main.GetComponent<PlayerCamera>();
	}

	// Token: 0x060006CE RID: 1742 RVA: 0x0003AF70 File Offset: 0x00039170
	private void FindFootOffsets()
	{
		this.footOffsetRight = this.rightFoot.transform.position.y - base.transform.position.y;
		this.footOffsetLeft = this.leftFoot.transform.position.y - base.transform.position.y;
	}

	// Token: 0x060006CF RID: 1743 RVA: 0x0003AFE1 File Offset: 0x000391E1
	public void LookAtPoint(Vector3 point)
	{
		if (this.head != null)
		{
			this.head.LookAtPoint(point);
		}
	}

	// Token: 0x060006D0 RID: 1744 RVA: 0x0003AFFA File Offset: 0x000391FA
	public void DisableLookAt()
	{
		if (this.head != null)
		{
			this.head.DisableLookAt();
		}
	}

	// Token: 0x060006D1 RID: 1745 RVA: 0x0003B012 File Offset: 0x00039212
	public void EnableLookAt()
	{
		if (this.head != null)
		{
			this.head.Cancel();
		}
	}

	// Token: 0x060006D2 RID: 1746 RVA: 0x0003B02A File Offset: 0x0003922A
	private void OnDestroy()
	{
		if (this.hand != null)
		{
			this.hand.ReleaseTarget();
		}
	}

	// Token: 0x060006D3 RID: 1747 RVA: 0x0003B044 File Offset: 0x00039244
	private void Start()
	{
		this.hand = new HandIK(this.ik, this.giantess);
		this.poseIK = new PoseIK(this, this.ik, this.lookAtIK, this.giantess);
		this.rightFootEffector.position = this.rightFoot.position;
		this.leftFootEffector.position = this.leftFoot.position;
		this.bodyEffector.position = this.hips.position;
		this.footEffect = base.GetComponent<FootEffect>();
		this.animManager = base.GetComponent<AnimationManager>();
		if (this.rightShoulder)
		{
			this.handBones = this.rightShoulder.GetComponentsInChildren<GiantessBone>();
			for (int i = 0; i < this.handBones.Length; i++)
			{
				this.handBones[i].canCrush = false;
			}
		}
		if (this.useGrounder)
		{
			this.grounder.solver.footRadius = this.giantess.Scale * 75f;
			this.grounder.solver.maxStep = this.giantess.Scale * 600f;
		}
	}

	// Token: 0x060006D4 RID: 1748 RVA: 0x0003B175 File Offset: 0x00039375
	private void MakeConvex(MeshCollider collider)
	{
		if (collider == null)
		{
			return;
		}
		collider.inflateMesh = true;
	}

	// Token: 0x060006D5 RID: 1749 RVA: 0x0003B18B File Offset: 0x0003938B
	private void MakeConcave(MeshCollider collider)
	{
		if (collider == null)
		{
			return;
		}
		collider.enabled = false;
		collider.inflateMesh = false;
		collider.enabled = true;
	}

	// Token: 0x060006D6 RID: 1750 RVA: 0x0003B1AF File Offset: 0x000393AF
	public void SetPoseMode(bool pose)
	{
		if (this.poseMode == pose)
		{
			return;
		}
		this.poseMode = pose;
		if (pose)
		{
			this.EnableIK(false);
		}
		else
		{
			this.SetPoseIK(false);
			this.SetDefaultValues();
		}
	}

	// Token: 0x060006D7 RID: 1751 RVA: 0x0003B1E4 File Offset: 0x000393E4
	public void EnableIK(bool value)
	{
		this.EnableBodyIK(value);
		this.lookAtIK.enabled = value;
	}

	// Token: 0x060006D8 RID: 1752 RVA: 0x0003B1F9 File Offset: 0x000393F9
	public void EnableBodyIK(bool value)
	{
		if (this.ik.enabled == value)
		{
			return;
		}
		this.ik.enabled = value;
	}

	// Token: 0x060006D9 RID: 1753 RVA: 0x0003B219 File Offset: 0x00039419
	public void SetPoseIK(bool value)
	{
		if (this.poseIK == null)
		{
			return;
		}
		if (value)
		{
			this.EnableIK(false);
			this.poseIK.ResetEffectors();
		}
		else
		{
			this.poseIK.SetWeight(0f);
		}
	}

	// Token: 0x060006DA RID: 1754 RVA: 0x0003B254 File Offset: 0x00039454
	private void SetDefaultValues()
	{
		this.ik.fixTransforms = false;
		this.ik.solver.headMapping.maintainRotationWeight = 0.6f;
		this.ik.solver.leftArmChain.reach = 0f;
		this.ik.solver.rightArmChain.reach = 0f;
		this.ik.solver.spineMapping.twistWeight = 0f;
		this.ik.solver.spineStiffness = 0f;
		this.ik.solver.pullBodyHorizontal = 0f;
		this.ik.solver.pullBodyVertical = 0f;
		this.ik.solver.rightLegMapping.maintainRotationWeight = 0.6f;
		this.ik.solver.rightLegChain.reach = 0.2f;
		this.ik.solver.leftLegMapping.maintainRotationWeight = 0.6f;
		this.ik.solver.leftLegChain.reach = 0.2f;
		if (this.head != null)
		{
			this.head.SetDefaultValues();
		}
	}

	// Token: 0x060006DB RID: 1755 RVA: 0x0003B394 File Offset: 0x00039594
	private void FixedUpdate()
	{
		if (this.poseMode)
		{
			return;
		}
		if (!this.luaIKEnabled && this.hand != null)
		{
			this.hand.Update();
		}
		if (this.head != null)
		{
			this.head.Update();
		}
	}

	// Token: 0x060006DC RID: 1756 RVA: 0x0003B3E4 File Offset: 0x000395E4
	private void Update()
	{
		if (this.poseMode)
		{
			return;
		}
		this.gtsScale = base.transform.lossyScale.y;
		this.currentGtsSpeed = this.animManager.GetCurrentSpeed();
		if (!this.useGrounder)
		{
			this.EnableBodyIK(this.footState != GiantessIK.FootStates.Idle || this.luaIKEnabled || (this.hand != null && this.hand.IsActive()));
		}
		if (!this.target)
		{
			this.SetTarget(this.playerCamera.target);
			if (!this.target)
			{
				return;
			}
		}
		this.UpdateButt();
		this.UpdateFeet();
		if (this.useGrounder)
		{
			this.grounder.solver.footRadius = this.giantess.Scale * 75f;
			this.grounder.solver.maxStep = this.giantess.Scale * 600f;
		}
	}

	// Token: 0x060006DD RID: 1757 RVA: 0x0003B4F8 File Offset: 0x000396F8
	private void LateUpdate()
	{
		if (this.poseMode)
		{
			return;
		}
		this.UpdateBones();
		if ((this.footState == GiantessIK.FootStates.Prepare || this.footState == GiantessIK.FootStates.Crush) && !this.IsClose(this.target))
		{
			this.footState = GiantessIK.FootStates.Return;
		}
	}

	// Token: 0x060006DE RID: 1758 RVA: 0x0003B547 File Offset: 0x00039747
	private void UpdateBones()
	{
		this.leftFootEffector.Update();
		this.rightFootEffector.Update();
		this.leftHandEffector.Update();
		this.rightHandEffector.Update();
		this.bodyEffector.Update();
	}

	// Token: 0x060006DF RID: 1759 RVA: 0x0003B580 File Offset: 0x00039780
	public void SetTarget(Transform target)
	{
		this.target = new TransformKinematic(target);
	}

	// Token: 0x060006E0 RID: 1760 RVA: 0x0003B58E File Offset: 0x0003978E
	public void SetTarget(Vector3 target)
	{
		this.target = new VectorKinematic(target);
	}

	// Token: 0x060006E1 RID: 1761 RVA: 0x0003B59C File Offset: 0x0003979C
	public void SetButtTarget(Vector3 target)
	{
		this.sitPosition = target;
		this.sit = true;
	}

	// Token: 0x060006E2 RID: 1762 RVA: 0x0003B5AC File Offset: 0x000397AC
	public void CancelButtTarget()
	{
		this.cancelButt = true;
	}

	// Token: 0x060006E3 RID: 1763 RVA: 0x0003B5B5 File Offset: 0x000397B5
	public void CancelFootCrush()
	{
		this.footState = GiantessIK.FootStates.Return;
	}

	// Token: 0x060006E4 RID: 1764 RVA: 0x0003B5C0 File Offset: 0x000397C0
	private void UpdateButt()
	{
		GiantessIK.ButtState buttState = this.buttState;
		float b = 0f;
		Vector3 b2 = this.bodyEffector.position;
		float num = 1f;
		GiantessIK.ButtState buttState2 = this.buttState;
		if (buttState2 != GiantessIK.ButtState.Idle)
		{
			if (buttState2 != GiantessIK.ButtState.Sitting)
			{
				if (buttState2 == GiantessIK.ButtState.Standing)
				{
					b = 0f;
					if (this.bodyEffector.positionWeight < 0.01f)
					{
						buttState = GiantessIK.ButtState.Idle;
					}
					else if (this.sit)
					{
						buttState = GiantessIK.ButtState.Sitting;
					}
				}
			}
			else
			{
				b = 1f;
				num = 0.3f;
				b2 = this.sitPosition + Vector3.up * this.ButtOffset * this.gtsScale;
				if (this.cancelButt)
				{
					this.cancelButt = false;
					buttState = GiantessIK.ButtState.Standing;
					this.sit = false;
				}
			}
		}
		else
		{
			b = 0f;
			if (this.sit)
			{
				buttState = GiantessIK.ButtState.Sitting;
				this.bodyEffector.position = this.hips.position;
				b2 = this.hips.position;
				Debug.Log("Starting Rotation: " + base.transform.localRotation);
			}
		}
		this.bodyEffector.rotationWeight = Mathf.Lerp(this.bodyEffector.rotationWeight, b, Time.deltaTime * num * this.currentGtsSpeed);
		this.bodyEffector.positionWeight = Mathf.Lerp(this.bodyEffector.positionWeight, b, Time.deltaTime * num * this.currentGtsSpeed);
		this.bodyEffector.position = Vector3.Lerp(this.bodyEffector.position, b2, Time.deltaTime * num * this.currentGtsSpeed);
		if (this.buttState != buttState)
		{
			Debug.Log("Next Butt State: " + buttState);
			this.buttState = buttState;
		}
	}

	// Token: 0x060006E5 RID: 1765 RVA: 0x0003B796 File Offset: 0x00039996
	public bool IsSit()
	{
		return this.buttState == GiantessIK.ButtState.Sitting;
	}

	// Token: 0x060006E6 RID: 1766 RVA: 0x0003B7A1 File Offset: 0x000399A1
	public void CrushTarget(EntityBase entity)
	{
		this.SetTarget(entity.transform);
		this.crushTarget = true;
		this.crushEnded = false;
	}

	// Token: 0x060006E7 RID: 1767 RVA: 0x0003B7BD File Offset: 0x000399BD
	public void CrushTarget(Vector3 targetPoint)
	{
		this.SetTarget(targetPoint);
		this.crushTarget = true;
		this.crushEnded = false;
	}

	// Token: 0x060006E8 RID: 1768 RVA: 0x0003B7D4 File Offset: 0x000399D4
	public void CrushManualTarget(Transform stompTarget)
	{
		this.SetTarget(stompTarget);
		this.manualStomp = true;
		this.crushTarget = true;
		this.crushEnded = false;
	}

	// Token: 0x060006E9 RID: 1769 RVA: 0x0003B7F4 File Offset: 0x000399F4
	private void UpdateFeet()
	{
		if (this.luaIKEnabled)
		{
			this.footState = GiantessIK.FootStates.Idle;
			return;
		}
		GiantessIK.FootStates nextFootState = this.footState;
		float weightSpeed = 1f;
		float weight = 1f;
		this.HandleFootCrush(nextFootState, weight, weightSpeed);
	}

	// Token: 0x060006EA RID: 1770 RVA: 0x0003B830 File Offset: 0x00039A30
	private void HandleFootCrush(GiantessIK.FootStates nextFootState, float weight, float weightSpeed)
	{
		float num = Time.deltaTime * GlobalPreferences.StompSpeed.value * this.currentGtsSpeed * 3f;
		switch (this.footState)
		{
		case GiantessIK.FootStates.Idle:
			this.leftFootEffector.position = this.leftFoot.position;
			this.rightFootEffector.position = this.rightFoot.position;
			if (this.crushTarget && this.animManager.TransitionEnded())
			{
				if (this.IsReachableByFeet(this.target) && this.IsClose(this.target))
				{
					float magnitude = (this.leftFoot.position - this.target.position).magnitude;
					float magnitude2 = (this.rightFoot.position - this.target.position).magnitude;
					if (this.leftFootCollider == null || this.rightFootCollider == null)
					{
						this.FindFeetColliders();
					}
					bool flag;
					if (this.manualStomp)
					{
						flag = (magnitude2 > magnitude);
					}
					else
					{
						flag = (4f + UnityEngine.Random.value + UnityEngine.Random.value < 10f * magnitude2 / (magnitude2 + magnitude));
					}
					if (flag)
					{
						this.activeFoot = this.leftFootEffector;
						this.activeFootNumber = 0;
						this.activeFootCollider = this.leftFootCollider;
						this.activeFootOffset = this.footOffsetLeft;
					}
					else
					{
						this.activeFoot = this.rightFootEffector;
						this.activeFootNumber = 1;
						this.activeFootCollider = this.rightFootCollider;
						this.activeFootOffset = this.footOffsetRight;
					}
					if (this.manualStomp)
					{
						this.randomOffset = Vector3.zero;
					}
					else
					{
						Vector2 vector = UnityEngine.Random.insideUnitCircle * 20f;
						this.randomOffset = this.activeFootCollider.transform.rotation * new Vector3(vector.x, 0f, vector.y * 4f);
					}
					Transform parent = GameController.playerInstance.transform.parent;
					GiantessBone giantessBone = null;
					if (parent != null)
					{
						giantessBone = parent.GetComponent<GiantessBone>();
					}
					if (parent == null || giantessBone == null || giantessBone.giantess != this.giantess)
					{
						this.MakeConvex(this.activeFootCollider);
					}
					nextFootState = GiantessIK.FootStates.Prepare;
				}
				else
				{
					nextFootState = GiantessIK.FootStates.Return;
				}
			}
			break;
		case GiantessIK.FootStates.Prepare:
			if (this.target)
			{
				this.footTarget = this.target.position + this.gtsScale * (Vector3.up * this.maxOffset - this.activeFootCollider.transform.forward * this.footForwardDisplacement + this.randomOffset);
			}
			else
			{
				nextFootState = GiantessIK.FootStates.Return;
			}
			if (this.FeetTargetIsChild(this.target))
			{
				nextFootState = GiantessIK.FootStates.Return;
			}
			if ((double)this.activeFoot.positionWeight > 0.75)
			{
				this.finalTargetAim = this.target.position;
				nextFootState = GiantessIK.FootStates.Crush;
				this.offsetPercentage = this.activeFoot.positionWeight;
			}
			break;
		case GiantessIK.FootStates.Crush:
		{
			this.offsetPercentage = Mathf.Lerp(this.offsetPercentage, -0.1f, num * 3f);
			this.offsetPercentage = Mathf.Max(this.offsetPercentage, 0f);
			float d = this.maxOffset * this.offsetPercentage + this.activeFootOffset;
			this.footTarget = this.finalTargetAim + this.gtsScale * (Vector3.up * d - this.activeFootCollider.transform.forward * this.footForwardDisplacement + this.randomOffset);
			if (this.offsetPercentage == 0f)
			{
				Vector3 point = this.finalTargetAim;
				RaycastHit raycastHit;
				if (Physics.Raycast(this.activeFoot.position + Vector3.up * this.gtsScale, Vector3.down, out raycastHit, float.PositiveInfinity, Layers.gtsWalkableMask))
				{
					point = raycastHit.point;
				}
				this.footEffect.DoStep(point + base.transform.forward * 100f * this.gtsScale, 3f, this.activeFootNumber);
				this.footTarget = this.activeFoot.position;
				this.footWaitTime = 0f;
				nextFootState = GiantessIK.FootStates.Wait;
			}
			break;
		}
		case GiantessIK.FootStates.Wait:
			this.footWaitTime += num;
			if ((double)this.footWaitTime > 1.2)
			{
				int num2 = UnityEngine.Random.Range(0, 4);
				if (!true)
				{
					this.turnOffsetPercentage = 1f;
					this.footStartingAngles = this.activeFoot.rotation.eulerAngles;
					nextFootState = GiantessIK.FootStates.Grind1;
				}
				else
				{
					nextFootState = GiantessIK.FootStates.Retract;
				}
			}
			break;
		case GiantessIK.FootStates.Grind1:
			this.turnOffsetPercentage = Mathf.Lerp(this.turnOffsetPercentage, 0f, num * 3f);
			this.footTargetAngles = this.footStartingAngles + this.grind1 * this.turnOffsetPercentage;
			if (this.turnOffsetPercentage < 0.15f)
			{
				Debug.Log("here");
				this.turnOffsetPercentage = 1f;
				this.footStartingAngles = this.activeFoot.rotation.eulerAngles;
				nextFootState = GiantessIK.FootStates.Grind2;
			}
			break;
		case GiantessIK.FootStates.Grind2:
			this.turnOffsetPercentage = Mathf.Lerp(this.turnOffsetPercentage, 0f, num * 1.5f);
			this.footTargetAngles = this.footStartingAngles + this.grind2 * this.turnOffsetPercentage;
			if (this.turnOffsetPercentage < 0.15f)
			{
				nextFootState = GiantessIK.FootStates.Retract;
			}
			break;
		case GiantessIK.FootStates.Retract:
		{
			this.offsetPercentage = Mathf.Lerp(this.offsetPercentage, 1f, num * this.retractSpeed);
			float d2 = this.maxOffset * this.offsetPercentage + this.activeFootOffset;
			this.footTarget = this.finalTargetAim + this.gtsScale * (Vector3.up * d2 - this.activeFootCollider.transform.forward * this.footForwardDisplacement + this.randomOffset);
			if (this.offsetPercentage > 0.5f)
			{
				nextFootState = GiantessIK.FootStates.Return;
			}
			break;
		}
		case GiantessIK.FootStates.Return:
			weight = -0.2f;
			weightSpeed = this.returnSpeed;
			if (this.activeFoot == null)
			{
				this.activeFoot = this.rightFootEffector;
			}
			if (this.activeFoot.positionWeight < 0f)
			{
				nextFootState = GiantessIK.FootStates.Idle;
				this.MakeConcave(this.activeFootCollider);
				this.crushEnded = true;
				this.crushTarget = false;
				this.manualStomp = false;
			}
			break;
		}
		if (this.footState != GiantessIK.FootStates.Idle)
		{
			this.activeFoot.positionWeight = Mathf.Lerp(this.activeFoot.positionWeight, weight, num * weightSpeed);
			this.activeFoot.position = this.footTarget;
		}
		if (this.footState == GiantessIK.FootStates.Grind1 || this.footState == GiantessIK.FootStates.Grind2)
		{
			this.activeFoot.rotation.eulerAngles = this.footTargetAngles;
		}
		if (this.footState == GiantessIK.FootStates.Idle || this.activeFoot != this.leftFootEffector)
		{
			this.leftFootEffector.positionWeight = Mathf.Lerp(this.leftFootEffector.positionWeight, this.minFootWeight, num);
		}
		if (this.footState == GiantessIK.FootStates.Idle || this.activeFoot != this.rightFootEffector)
		{
			this.rightFootEffector.positionWeight = Mathf.Lerp(this.rightFootEffector.positionWeight, this.minFootWeight, num);
		}
		this.footState = nextFootState;
	}

	// Token: 0x060006EB RID: 1771 RVA: 0x0003C038 File Offset: 0x0003A238
	private bool IsClose(IKinematic victim)
	{
		return victim && this.IsClose(victim.position);
	}

	// Token: 0x060006EC RID: 1772 RVA: 0x0003C054 File Offset: 0x0003A254
	public bool IsClose(Vector3 targetPos)
	{
		Vector3 vector = base.transform.position - (targetPos - base.transform.forward * this.footForwardDisplacement * this.gtsScale);
		vector.y = 0f;
		return vector.magnitude < this.maxDistanceFoot * 1600f * this.gtsScale;
	}

	// Token: 0x060006ED RID: 1773 RVA: 0x0003C0C1 File Offset: 0x0003A2C1
	private bool IsReachableByFeet(IKinematic victim)
	{
		return victim && !this.FeetTargetIsChild(victim) && this.FeetTargetIsInRange(victim);
	}

	// Token: 0x060006EE RID: 1774 RVA: 0x0003C0E4 File Offset: 0x0003A2E4
	private bool FeetTargetIsChild(IKinematic victim)
	{
		TransformKinematic transformKinematic = victim as TransformKinematic;
		return transformKinematic != null && transformKinematic.transform.parent != null && transformKinematic.transform.parent.gameObject.layer == Layers.gtsBodyLayer;
	}

	// Token: 0x060006EF RID: 1775 RVA: 0x0003C138 File Offset: 0x0003A338
	private bool FeetTargetIsInRange(IKinematic victim)
	{
		float num = Mathf.Abs(base.transform.InverseTransformPoint(victim.position).y);
		return num < this.maxOffset;
	}

	// Token: 0x060006F0 RID: 1776 RVA: 0x0003C170 File Offset: 0x0003A370
	private void FindFeetColliders()
	{
		for (int i = 0; i < this.rightFoot.childCount; i++)
		{
			if (this.rightFoot.GetChild(i).name.StartsWith("Coll"))
			{
				this.rightFootCollider = this.rightFoot.GetChild(i).GetComponent<MeshCollider>();
				break;
			}
		}
		for (int j = 0; j < this.leftFoot.childCount; j++)
		{
			if (this.leftFoot.GetChild(j).name.StartsWith("Coll"))
			{
				this.leftFootCollider = this.leftFoot.GetChild(j).GetComponent<MeshCollider>();
				break;
			}
		}
	}

	// Token: 0x060006F1 RID: 1777 RVA: 0x0003C230 File Offset: 0x0003A430
	public bool IsCloserToLeftFoot(Vector3 pos)
	{
		float magnitude = (this.leftFoot.position - pos).magnitude;
		float magnitude2 = (this.rightFoot.position - pos).magnitude;
		return magnitude2 > magnitude;
	}

	// Token: 0x060006F2 RID: 1778 RVA: 0x0003C278 File Offset: 0x0003A478
	private void OnDrawGizmos()
	{
		if (this.target)
		{
			Gizmos.color = Color.red;
			Gizmos.DrawWireCube(this.target.position, new Vector3(3f, 3f, 3f));
			Gizmos.DrawWireSphere(this.footTarget - this.activeFootOffset * Vector3.up * this.gtsScale, 1f);
		}
	}

	// Token: 0x04000AFE RID: 2814
	public bool luaIKEnabled;

	// Token: 0x04000AFF RID: 2815
	private FullBodyBipedIK ik;

	// Token: 0x04000B00 RID: 2816
	private LookAtIK lookAtIK;

	// Token: 0x04000B01 RID: 2817
	private GrounderFBBIK grounder;

	// Token: 0x04000B02 RID: 2818
	private PlayerCamera playerCamera;

	// Token: 0x04000B03 RID: 2819
	private Animator anim;

	// Token: 0x04000B04 RID: 2820
	private FootEffect footEffect;

	// Token: 0x04000B05 RID: 2821
	private Giantess giantess;

	// Token: 0x04000B06 RID: 2822
	private IKinematic target;

	// Token: 0x04000B07 RID: 2823
	private bool manualStomp;

	// Token: 0x04000B08 RID: 2824
	private Transform headT;

	// Token: 0x04000B09 RID: 2825
	private Transform rightFoot;

	// Token: 0x04000B0A RID: 2826
	private Transform leftFoot;

	// Token: 0x04000B0B RID: 2827
	private Transform rightShoulder;

	// Token: 0x04000B0C RID: 2828
	private Transform hips;

	// Token: 0x04000B0D RID: 2829
	private AnimationManager animManager;

	// Token: 0x04000B0E RID: 2830
	private bool useGrounder;

	// Token: 0x04000B10 RID: 2832
	private bool crushTarget;

	// Token: 0x04000B11 RID: 2833
	private readonly float maxOffset = 400f;

	// Token: 0x04000B12 RID: 2834
	private readonly float returnSpeed = 2f;

	// Token: 0x04000B13 RID: 2835
	private readonly float maxDistanceFoot = 0.35f;

	// Token: 0x04000B14 RID: 2836
	private readonly float retractSpeed = 0.5f;

	// Token: 0x04000B15 RID: 2837
	private float footWaitTime;

	// Token: 0x04000B16 RID: 2838
	private readonly float footForwardDisplacement = 40f;

	// Token: 0x04000B17 RID: 2839
	private Vector3 footTarget;

	// Token: 0x04000B18 RID: 2840
	private Vector3 footTargetAngles;

	// Token: 0x04000B19 RID: 2841
	private Vector3 randomOffset;

	// Token: 0x04000B1A RID: 2842
	private int mWalkableLayer;

	// Token: 0x04000B1B RID: 2843
	private GiantessIK.FootStates footState;

	// Token: 0x04000B1C RID: 2844
	private float minFootWeight = -0.3f;

	// Token: 0x04000B1D RID: 2845
	private float offsetPercentage = 1f;

	// Token: 0x04000B1E RID: 2846
	private IKBone rightFootEffector;

	// Token: 0x04000B1F RID: 2847
	private IKBone leftFootEffector;

	// Token: 0x04000B20 RID: 2848
	private IKBone activeFoot;

	// Token: 0x04000B21 RID: 2849
	private int activeFootNumber;

	// Token: 0x04000B22 RID: 2850
	private MeshCollider rightFootCollider;

	// Token: 0x04000B23 RID: 2851
	private MeshCollider leftFootCollider;

	// Token: 0x04000B24 RID: 2852
	private MeshCollider activeFootCollider;

	// Token: 0x04000B25 RID: 2853
	private float footOffsetRight;

	// Token: 0x04000B26 RID: 2854
	private float footOffsetLeft;

	// Token: 0x04000B27 RID: 2855
	private float activeFootOffset;

	// Token: 0x04000B2A RID: 2858
	private IKBone bodyEffector;

	// Token: 0x04000B2B RID: 2859
	private GiantessIK.ButtState buttState;

	// Token: 0x04000B2C RID: 2860
	private Vector3 sitPosition;

	// Token: 0x04000B2D RID: 2861
	private bool sit;

	// Token: 0x04000B2E RID: 2862
	private float ButtOffset = 180f;

	// Token: 0x04000B2F RID: 2863
	private bool cancelButt;

	// Token: 0x04000B30 RID: 2864
	private GiantessBone[] handBones;

	// Token: 0x04000B31 RID: 2865
	private float gtsScale;

	// Token: 0x04000B32 RID: 2866
	private float currentGtsSpeed = 1f;

	// Token: 0x04000B36 RID: 2870
	private bool poseMode;

	// Token: 0x04000B37 RID: 2871
	private Vector3 finalTargetAim;

	// Token: 0x04000B38 RID: 2872
	private Vector3 footStartingAngles;

	// Token: 0x04000B39 RID: 2873
	private Vector3 grind1 = new Vector3(0f, 30f, 0f);

	// Token: 0x04000B3A RID: 2874
	private Vector3 grind2 = new Vector3(0f, -60f, 0f);

	// Token: 0x04000B3B RID: 2875
	private float turnOffsetPercentage;

	// Token: 0x02000172 RID: 370
	public enum FootStates
	{
		// Token: 0x04000B3D RID: 2877
		Idle,
		// Token: 0x04000B3E RID: 2878
		Prepare,
		// Token: 0x04000B3F RID: 2879
		Crush,
		// Token: 0x04000B40 RID: 2880
		Wait,
		// Token: 0x04000B41 RID: 2881
		Grind1,
		// Token: 0x04000B42 RID: 2882
		Grind2,
		// Token: 0x04000B43 RID: 2883
		Retract,
		// Token: 0x04000B44 RID: 2884
		Return
	}

	// Token: 0x02000173 RID: 371
	private enum ButtState
	{
		// Token: 0x04000B46 RID: 2886
		Idle,
		// Token: 0x04000B47 RID: 2887
		Sitting,
		// Token: 0x04000B48 RID: 2888
		Sit,
		// Token: 0x04000B49 RID: 2889
		Standing
	}
}
